<?php



set_time_limit(0);
define('IN_WT', true);
include 'include.php';
include 'config.php';

$db = mysqlDB::con();
$sql = 'SELECT `Blog_Feed` FROM blog_info WHERE `Blog_State` =1';
#得到源列表
$blogRss = $db->getOneArr($sql);
$int = count($blogRss) - 1;
$RSS = array();
foreach ($blogRss as $feed)
{
	$num = mt_rand(0, $int);
	$feed = !empty($blogRss[$num]) ? $blogRss[$num] : '';
	unset($blogRss[$num]);
	if(empty($feed))
	{
		continue;
	}
	echo $feed . '<br>' . "\n";
	$i = 0;
	#获得源的文章列表
	$feed = 'http://www.phppan.com/feed/rss/';
	$xmls = new wt_xml($feed);
	$RSS = $xmls->getRSS();
	#print_r($RSS);exit;
	$BID = wt_post::getBlogID($feed);
	if (!empty($RSS['post']))
	{
		#print_r($RSS['post']);exit;
		foreach (array_reverse($RSS['post']) as $v)
		{
			if (empty($v['postPubDate']))
			{
				$pid = wt_post::postLink2pid($v['postLink']);
			}
			else
			{
				$pid = true;
				$v['postPubDate'] = wt_post::strtotimeExtend($v['postPubDate']);
			}
			#$v['postPubDate'] = empty($v['postPubDate']) ? time() : strtotime($v['postPubDate']);
			if (wt_post::getLastUpdate($feed) < $v['postPubDate'] || !$pid)
			{
				$i ++;
				echo '.';
				wt_post::addPost($v, $BID);
			}
			if ($i > 0)
			{
				echo 'ds';
				wt_post::clearCache($BID);
				wt_post::creatCache($BID);
			}
		}
	}
	exit;
}







